var private file ;
var private i = 1, ele[3], uv[2][2];
var private temp, suf_flag = OFF, atr_flag = OFF;

Bunkai(GetArg( 0 ), ele );
model_dir = ele[0];

if( MACHINE == "WINDOWS" )
	Child( model_dir+"exec_bin "+model_dir+"agcv_mdl.bin 8000 8100" );
InputMode( INPUT, CURSOR );
MakeButton();
StatusInit();
if( buttondisp_flag == OFF )
	ButtonArea( 0 );
else
	ButtonArea(BUTTONAREA);
SetZoom( -zoomsize );
SetGrid( mesh_grid, mouse_grid );
PersAngle(pers_deg);
ControlEvent( _InputVertex );
AttrEvent( _AttrEvent );
ObjEvent( _ObjEvent );
CanCloseEvent( QuitModel );

while ( GetArg( i ) != "" )
{
	file = GetArg( i );
	if( ( substr( file, 1 ) == "-" ) | ( substr( file, 1 ) == "/" ) )
	{
		temp = toupper(substr( file, ((-1)*(!file)+1)));
		if( temp == "V" )
			housendisp_flag = ON;
	}
	else if ( toupper(substr( file, -4 )) == ".ATR" )
	{
		AttrReadFile( file );
		if( access( file ) == TRUE )
		{
			UpdateAttribute();
			atr_flag = ON;
		}
	}
	else
	{
		file = MakeFile( file, "suf" );
		if( access( file ) == TRUE )
		{
			ReadFile( file );
			file = substr( file, !file-4 ) + ".atr" ;
			if ( access( file ) )
				AttrReadFile( file );
			SelectAll( FALSE );
			suf_flag = ON;
			atr_flag = ON;
		}
		else
		{
			Warning();
			Message( file+"が見つかりません" );
		}
	}
	i++ ;
}
if( atr_flag == OFF )
{
	AttrAppend( default_atrname, default_atrcode );
	AttrFile( 0, default_atrfile );
	if( EXPERT != TRUE )
	{
		AttrMap( 0, TRUE );
		AttrMapFile( 0, MAPPINGFILE );
		uv[0] = {0,0};
		uv[1] = {MAPWIND-1, MAPWIND-1};
		SetAttrMapWind( 0, uv[0], uv[1] );
		uv[0] = {0,0};
		uv[1] = {UVMAX-1, UVMAX-1};
		SetAttrMapSize( 0, uv[0], uv[1] );
	}
}

if( suf_flag == OFF )
{
	ObjAppend( default_objname, default_filename );
	UpdateObject();
}

if( housendisp_flag == ON )
	VisibleVector( vecvisible_len );
if( tendisp_flag == ON )
{
	VisibleVertex( 1 );
}
DrawInvisible( drawinvisible_flag );
UpdateAll();
Polygon();
